# -*- coding:utf-8 -*-
from gwlsa_settings import net_params
from utils.landslide_utils import load_df_fromfile

def pkl_to_csv(csv_saved_dir ='./data_split_csv/RasterUnits20220905_20240915_025555_D32res30'):
    train_df, val_df, test_df = load_df_fromfile(net_params['data_load_dir'],
                                                 buffer_distance=net_params['max_distance'],
                                                 resolution=net_params['resolution'],
                                                 file_format=net_params['data_load_format'])
    drop_columns = ['posX', 'posY', 'distances', 'neighbours', 'xb']
    train_df.drop(drop_columns, axis=1, inplace=True)
    val_df.drop(drop_columns, axis=1, inplace=True)
    test_df.drop(drop_columns, axis=1, inplace=True)

    train_df.to_csv(f'{csv_saved_dir}/train.csv', encoding='utf-8', index=False)
    val_df.to_csv(f'{csv_saved_dir}/val.csv', encoding='utf-8', index=False)
    test_df.to_csv(f'{csv_saved_dir}/test.csv', encoding='utf-8', index=False)

    print(train_df.columns)
    print(type(train_df))

if __name__ == '__main__':
    pkl_to_csv(csv_saved_dir='./data_split_csv/RasterUnits20220905_20241031_121533_D32res30')
